<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@page import="com.lmpop.trade.ti_inquiry.*" %>
<%@page import="com.lmpop.trade.ti_re_inquiry.*" %>
<%@page import="java.util.*" %>
<%@page import="com.lmpop.frame.util.PageTools" %>
<%@page import="com.lmpop.createIndex.search.BizInfoIndexFiles"%>
<%@ page import="com.lmpop.trade.ti_payment.*" %>
<%
	request.setCharacterEncoding("UTF-8");
	Map  ti_inquiry = new Hashtable();
	Ti_re_inquiryInfo ti_re_inquiryInfo = new Ti_re_inquiryInfo();
	BizInfoIndexFiles bizInfoIndex = new BizInfoIndexFiles();
	Ti_paymentInfo payment = new Ti_paymentInfo();
	
	
	String session_cust_id="",rsrv_str1_s="",start_date="",end_date="",s_trade_id="",rsrv_str2="";
	if(session.getAttribute("session_cust_id")!=null){
	  session_cust_id=session.getAttribute("session_cust_id").toString();  
	  //ti_inquiry.put("cust_id",session_cust_id);
	}
	if(request.getParameter("s_trade_id")!=null && !request.getParameter("s_trade_id").equals("")){
		s_trade_id = request.getParameter("s_trade_id");
		ti_inquiry.put("trade_id",s_trade_id);
	}
	if(request.getParameter("rsrv_str2")!=null && !request.getParameter("rsrv_str2").equals("")){
		rsrv_str2 = request.getParameter("rsrv_str2");
		ti_inquiry.put("rsrv_str2",rsrv_str2);
	}
	ti_inquiry.put("biz_type","f");
	String s_title = "";
	if(request.getParameter("search_name")!=null && !request.getParameter("search_name").equals("")){
		s_title = request.getParameter("search_name"); 
		ti_inquiry.put("goods_name",s_title);
	}
	if(request.getParameter("rsrv_str1")!=null && !request.getParameter("rsrv_str1").equals("")){
		rsrv_str1_s = request.getParameter("rsrv_str1");
		ti_inquiry.put("rsrv_str1",rsrv_str1_s);
	}
	
	if(request.getParameter("start_date")!=null && !request.getParameter("start_date").equals("")){
		start_date = request.getParameter("start_date");
		ti_inquiry.put("start_date",start_date);
	}
	if(request.getParameter("end_date")!=null && !request.getParameter("end_date").equals("")){
		end_date = request.getParameter("end_date");
		ti_inquiry.put("end_date",end_date);
	}
	
	Ti_inquiryInfo ti_inquiryInfo = new Ti_inquiryInfo();
	String iStart = "0";
	int limit = 20;
	if(request.getParameter("iStart")!=null) iStart = request.getParameter("iStart");   
	List list = ti_inquiryInfo.getListByPage(ti_inquiry,Integer.parseInt(iStart),limit);
	int counter = ti_inquiryInfo.getCountByObj(ti_inquiry);
	String pageString = new PageTools().getGoogleToolsBar(counter,"index.jsp?search_name="+s_title+"&start_date="+start_date+"&end_date="+end_date+"&rsrv_str1="+rsrv_str1_s+"&rsrv_str2="+rsrv_str2+"&iStart=",Integer.parseInt(iStart),limit);
%>
<html>
  <head>
    
    <title>批发订单</title>
	<link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="/js/commen.js"></script>
	<script type="text/javascript" src="inquiry.js"></script>
		<script language="javascript" type="text/javascript" src="/program/plugins/calendar/WdatePicker.js"></script>
</head>

<body>
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td width="90%">
				<h1>批发订单</h1>
			</td>
			<td>
				<!--<a href="addInfo.jsp"><img src="/program/company/index/images/post.gif" /></a>-->
			</td>
		</tr>
	</table>
	
	<form action="index.jsp" name="indexForm" method="post">
	
	<!--
	<table width="100%" align="center" cellpadding="0" cellspacing="0" class="dl_so">
        <tr>
          <td width="9%" align="center"><img src="/program/admin/index/images/ban_01.gif" /></td>
          <td width="91%" align="left">
		  <h4>-----------------</h4>
		  <span>1----------------。</span><br/>
		  <span>2----------------。</span>
		  </td>
        </tr>
      </table>
      <br/>
	  -->
	  
	<table width="100%" cellpadding="0" cellspacing="0" class="dl_su">
		<tr>
			<td align="left" >
			按处理状态：			
			<select name="rsrv_str2">					 
				  <option value="">全部订单</option>
					<option value="0">未处理</option>
					<option value="1">正在处理</option>
					<option value="2">已处理</option>
				</select>
				
			按订单号：<input name="s_trade_id" id="s_trade_id" type="text" />		
			按商品名称：<input name="search_name" id="search_name" type="text" /><br>
			付款状态：
				<select name="rsrv_str1">
					<option value="">全部订单</option>
					<option value="0">未付款的订单</option>
					<option value="1">已付款的订单</option>
					<option value="2">货到付款的订单</option>
				</select>
			下单时间:<input name="start_date" type="text" id="start_date" class="Wdate" value="" onclick="WdatePicker({maxDate:'#F{$dp.$D(\'end_date\',{d:-1})}',readOnly:true})" size="15"  width="150px"/>
								~
							 <input name="end_date" id="end_date" type="text" class="Wdate" value="" onclick="WdatePicker({minDate:'#F{$dp.$D(\'start_date\',{d:1})}',readOnly:true})" size="15" width="150px"/>
				
				<input name="searchInfo" type="button" value="搜索" onClick="searchForm()"/>	
			 
			</td>
		</tr>
	</table>

	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td><%=pageString %></td></tr>
	</table>
	
	<% 
		int listsize = 0;
		if(list!=null && list.size()>0){
			listsize = list.size();
	%>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
				<input type="button" name="delInfo" onClick="delIndexInfo()" value="删除" class="buttab"/>
			</td>
			<td>
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	
	<table width="100%" cellpadding="1" cellspacing="1" class="listtab" border="0">
		<tr>
			<th width="5%" align="center"><input type="checkbox" name="checkall" id="checkall" onClick="selectAll()"></th>
			  <th>会员名称</th>
		  	<th>商机</th>
		  	
		  	<th>标题</th>
		  	
		  	 
		  	
		  	<th>规格明细</th>
			
		  	<th>下单时间</th>
		  	
			<th width="12%">操作</th>
	  	<th width="10%">删除</th>
		</tr>
		
		
		<% 
		  		for(int i=0;i<list.size();i++){
		  			Hashtable map = (Hashtable)list.get(i);
		  			String trade_id="",info_id="",title="",order_num="",goods_name="",req_price="",in_date="",rsrv_str1="",rsrv_str2_s="",user_id="",payments="",cust_name=""; 
		  			  	if(map.get("trade_id")!=null) trade_id = map.get("trade_id").toString();
						if(map.get("goods_name")!=null) goods_name = map.get("goods_name").toString();
						if(map.get("info_id")!=null) info_id = map.get("info_id").toString();
						if(map.get("title")!=null) title = map.get("title").toString();
						if(map.get("order_num")!=null) order_num = map.get("order_num").toString();
						if(map.get("req_price")!=null) req_price = map.get("req_price").toString();
						if(map.get("user_id")!=null) user_id = map.get("user_id").toString();
						if(map.get("cust_name")!=null) cust_name = map.get("cust_name").toString();
						if(map.get("rsrv_str1")!=null) rsrv_str1 = map.get("rsrv_str1").toString();
						if(map.get("rsrv_str2")!=null) rsrv_str2_s = map.get("rsrv_str2").toString();
						if(map.get("in_date")!=null) in_date = map.get("in_date").toString();
						
						if(in_date.length()>19)in_date=in_date.substring(0,19);
						
 						List relist = ti_re_inquiryInfo.getListByPk(trade_id);
 						
 						Map bizmap=bizInfoIndex.getOneBizInfo(info_id);
 						if(bizmap!=null)
						{
							if(bizmap.get("payments")!=null) payments = bizmap.get("payments").toString();
						}

		  %>
		
		<tr>
			<td width="5%" align="center"><input type="checkbox" name="checkone<%=i %>" id="checkone<%=i %>" value="<%=trade_id %>" /></td>
			<td width="10%"><%=cust_name%>&nbsp;</td>
		  	<td width="10%"><%=goods_name%>&nbsp;</td>
		  	
		  	<td width="20%"><%=title%>&nbsp;<p style="font-weight:bold;color:blue">订单号：<%=trade_id%></p></td>
		  	
		   
		  	
		  	 <td><a href="modellist.jsp?trade_id=<%=trade_id%>">查看规格明细</a></td>
			
			<td><%=in_date%>&nbsp;</td>
			<td width="10%">	
				
		 	<%
		  	if (rsrv_str2_s.equals("0")) rsrv_str2_s = "<font color=#000>未处理</font>";
		  	if (rsrv_str2_s.equals("1")) rsrv_str2_s = "<font color=red>处理中</font>";
		  	if (rsrv_str2_s.equals("2")) rsrv_str2_s = "<font color=green>已处理</font>";
		  %>
		  [<%=rsrv_str2_s%>]
		  <%	
		  	if (rsrv_str1.equals("1") && (relist==null || relist.size()<=0))
		  	{
		  %>		  	
			在线支付-等待发货
			 
			<%
				}
				if ((relist!=null && relist.size()>0) && rsrv_str1.equals("1"))
				{
			%>
				在线支付-已处理发货
			<%
				}
				if ((relist!=null && relist.size()>0) && rsrv_str1.equals("2"))
				{
			%>
				货到付款-处理完成
			<%
				}
				if ((relist==null || relist.size()<=0) && rsrv_str1.equals("0"))
				{				
			%>
		
				<%
        	if (!payments.equals(""))
        	{            			
	      		String pay[]=payments.split("\\|");
	      		String pay_code="",pay_name="";
						for(int j=0;j<pay.length;j++)
						{
							if(!pay[j].equals(""))
							{											 
							 	List paylist = payment.getListByPk(pay[j]);
								if(paylist != null && paylist.size() >0)
								{
									Map paymap = (Hashtable)paylist.get(0);
									if (paymap.get("pay_code") != null) pay_code = paymap.get("pay_code").toString();
									if (paymap.get("pay_name") != null) pay_name = paymap.get("pay_name").toString();
									if (pay_code.equals("alipay"))
									{
									%>
									<%=pay_name%>
									<%
									}
									else if (pay_code.equals("chinabank"))
									{
									%>
									<%=pay_name%> 
									<%
									}
									else if (pay_code.equals("99bill"))
									{
									%>
									<%=pay_name%>
									<%
									}																																 
								}
							}
						}
					}									
        %>
				
				
					
				
	  	
	  	<%
	  		}
	  		if ((relist==null || relist.size()<=0) && rsrv_str1.equals("2"))
				{
	  	%>
	    货到付款，等待发货
	  	<%
	  		}
	  	%>
	  	</td>
	  	<td width="10%"><a href="javascript:deleteOneInfo('<%=trade_id%>','2487');"><img src="/program/admin/images/delete.gif" title="删除" /></a></a></td>
		</tr>
		
		  <%
		  		}
		  %>
		
	</table>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
				<input type="button" name="delInfo" onClick="delIndexInfo()" value="删除" class="buttab"/>
			</td>
			<td>
				总计：<%=counter %>条
			</td>
		</tr>
	</table>
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td><%=pageString %></td></tr>
	</table>
	
	<%
		 }
	%>
	
	  <input type="hidden" name="listsize" id="listsize" value="<%=listsize %>" />
	  <input type="hidden" name="pkid" id="pkid" value="" />
	  <input type="hidden" name="bpm_id" id="bpm_id" value="2487" />
	  </form>
</body>

</html>
